import axios from 'axios'
axios.defaults.baseURL = 'http://klxin.cn:8888/api/private/v1/'
//请求在到达服务器之前，先会调用use中的这个回调函数来添加请求头信息
axios.interceptors.request.use(config => {
  //为请求头对象，添加token验证的Authorization字段
  config.headers.Authorization = window.sessionStorage.getItem("token")
  return config
})

export var login_api = (params) => {
  return axios.post('login', params)
}

export var getmenuList_api = () => {
  return axios.get('menus')
}
//获取用户数据列表
export var getUserList_api = (params) => {
  return axios.get('users', {
    params
  })
}
//添加用户
export var addUsers_api = (params) => {
  return axios.post('users', params)
}
//修改用户状态

export var setStatus_api = (params) => {
  return axios.put(`users/${params.uId}/state/${params.type}`)
}
//获取权限列表
export var getRightList_api = (params) => {
  return axios.get(`rights/${params.type}`)
}
//获取所有权限
export var getRight_api = (params) => {
  return axios.get(`menus`)
}
export var getRoleList_api = (params) => {
  return axios.get('roles')
}
export var setRight_api = (params) => {
  return axios.post(`roles/${params.roleId}/rights`, params)
}
